﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApplicationGDI6._1Home
{
    public partial class Form1 : Form
    {

        public Form1()
        {
            //KnownColor = Color.Black;
            InitializeComponent();
        }

        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            using (Graphics gr = e.Graphics)
            {
                Pen p1 = new Pen(Color.Black);
                Font f1 = new Font("Jeff_Script", 10f);
                Brush b1 = new SolidBrush(Color.Red);
                gr.DrawString("f(x) = ", f1, b1, 10, 335);
                gr.DrawString("*", f1, b1, 64, 338);


            }
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            Enumer ez = new Enumer(typeof(KnownColor), this);
            ez.SetComboBoxPosition(12, 117);
            ez.onChanged += ez_onChanged;

            Enumer ez1 = new Enumer(typeof(KnownColor), this);
            ez1.SetComboBoxPosition(12, 158);
            ez.onChanged +=ez_onChanged;

            Enumer ez2 = new Enumer(typeof(GraphicsUnit), this);
            ez2.SetComboBoxPosition(12, 12);
            ez2.onChanged += ez2_onChanged;
        }

        void ez2_onChanged(Enumer sender, object value)
        {
            Invalidate();
        }

        void ez_onChanged(Enumer sender, object value)
        {
            Color color;
            try
            {
                color = Color.FromName(value.ToString());
            }
            catch (Exception e)
            {
                return;
            }
            //var1 = (Color)value;
            Invalidate();
        }
    }
}

// Color.FromName(Value.ToString());
/*
 * try {
 *  Color = Color.FromName(Value.ToString());
 * }catch (Exeption e)
 *  retrun;
 */